package cn.ywang.pattern.factory.simple;

import cn.ywang.pattern.factory.products.ring.GoldRing;
import cn.ywang.pattern.factory.products.ring.IRing;
import cn.ywang.pattern.factory.products.ring.PlatinumRing;

/**
 * 戒指工厂
 *
 * @author BeatificWang
 * @date 2019/3/10 9:54
 */
public class RingFactory {

	/**
	 * 根据材质创建不同的戒指
	 *
	 * @param name
	 * @return
	 */
	public IRing createRing(String name) {
		switch (name) {
			case "gold":
				return new GoldRing();
			case "platinum":
				return new PlatinumRing();
			default:
				throw new RuntimeException("没有符合要求的戒指");
		}
	}

}
